package com.huawei.hianalytics.ab.bc.de;

import android.text.TextUtils;
import com.huawei.hianalytics.ab.ab.bc;
import com.huawei.hianalytics.ab.bc.kl.de;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;

public class gh {
    private static gh ab = new gh();
    private ab bc = new ab(this);

    class ab {
        String ab;
        String bc;
        String cd;
        long de = 0;
        final /* synthetic */ gh ef;

        ab(gh ghVar) {
            this.ef = ghVar;
        }

        void ab(long j) {
            this.ef.bc.de = j;
        }

        void ab(String str) {
            this.ef.bc.ab = str;
        }

        void bc(String str) {
            this.ef.bc.bc = str;
        }

        void cd(String str) {
            this.ef.bc.cd = str;
        }
    }

    public static gh ab() {
        return ab;
    }

    private String fg() {
        Throwable th;
        String str = null;
        Closeable open;
        try {
            open = bc.ik().getResources().getAssets().open("hianalytics_njjn");
            try {
                str = de.ab((InputStream) open);
                de.ab(open);
            } catch (IOException e) {
                try {
                    com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "read pubKey error,the file is corrupted");
                    de.ab(open);
                    return str;
                } catch (Throwable th2) {
                    th = th2;
                    de.ab(open);
                    throw th;
                }
            }
        } catch (IOException e2) {
            open = str;
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "read pubKey error,the file is corrupted");
            de.ab(open);
            return str;
        } catch (Throwable th3) {
            Throwable th4 = th3;
            open = str;
            th = th4;
            de.ab(open);
            throw th;
        }
        return str;
    }

    public void bc() {
        long ef = ef();
        if (ef == 0) {
            ef = System.currentTimeMillis();
            String fg = fg();
            if (TextUtils.isEmpty(fg)) {
                com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "get rsa pubkey config error");
                return;
            }
            String bc = com.huawei.hianalytics.ab.bc.ab.bc.ab().bc(com.huawei.hianalytics.ab.bc.ab.bc.ab.AES);
            String bc2 = com.huawei.hianalytics.ab.bc.ab.bc.ab().ab(com.huawei.hianalytics.ab.bc.ab.bc.ab.RSA).bc(fg, bc);
            this.bc.ab(fg);
            this.bc.ab(ef);
            this.bc.bc(bc);
            this.bc.cd(bc2);
            return;
        }
        long currentTimeMillis = System.currentTimeMillis();
        if (currentTimeMillis - ef > 43200000) {
            String str = this.bc.ab;
            String bc3 = com.huawei.hianalytics.ab.bc.ab.bc.ab().bc(com.huawei.hianalytics.ab.bc.ab.bc.ab.AES);
            str = com.huawei.hianalytics.ab.bc.ab.bc.ab().ab(com.huawei.hianalytics.ab.bc.ab.bc.ab.RSA).bc(str, bc3);
            this.bc.ab(currentTimeMillis);
            this.bc.bc(bc3);
            this.bc.cd(str);
        }
    }

    public String cd() {
        return this.bc.bc;
    }

    public String de() {
        return this.bc.cd;
    }

    public long ef() {
        return this.bc.de;
    }
}
